//
//  PCDApiGotoIndex.m
//  PCDBankSix
//
//  Created by DK on 2022/3/5.
//

#import "PCDApiGotoIndex.h"
#import "PCDBankWebViewController.h"



@implementation PCDApiGotoIndex
- (void)handler:(id)data andContext:(PCDContext *)context ResponseCallback:(WVJBResponseCallback )responseCallback
{
    NSDictionary *tempDic = (NSDictionary *)data;
    NSString *callBack = [tempDic objectForKey:@"success"];
    
//    NSString *PAGE_INDEX_2 = [tempDic objectForKey:@"PAGE_INDEX_2"];
//
//    PCDBankWebViewController *view = context.viewController;
//
//    if (![PCDUtil nilOrEmptyString:PAGE_INDEX_2]) {
//        view.tabBarViewController.selectedIndex = 2;
//    }
//
//    [view.navigationController popToRootViewControllerAnimated:YES];
////    //清理所有栈内页面
////    NSMutableArray *viewCtrs =[self clearViews];
////
////    [PCDPageViewMangeGet().baseNavgatView setViewControllers:viewCtrs animated:NO];
//
//    if (![PCDUtil nilOrEmptyString:callBack]) {
//        //
//        evaluateJavaScriptOnMainThread(self,callBack,@"");
//    }
    
    
    
    PCDBankWebViewController *view = context.viewController;
    view.tabBarViewController.selectedIndex = 0;
    [view.navigationController popToRootViewControllerAnimated:YES];

}

-(NSMutableArray *)clearViews
{
    NSMutableArray *viewCtrs = [NSMutableArray arrayWithArray:PCDPageViewMangeGet().baseNavgatView.viewControllers];
    
    NSInteger i =viewCtrs.count-1;
    while (i>=0) {
        
        id view = [viewCtrs objectAtIndex:i];
        
        if ([view isKindOfClass:[PCDBankWebViewController class]]) {
            [viewCtrs removeObjectAtIndex:i];
            i--;
        }else{
            break;
        }

    }
    
    return viewCtrs;
}

@end
